
#ifndef _PROCESSROUTER_IOTHREAD_H_
#define _PROCESSROUTER_IOTHREAD_H_

#include <ev.h>
#include <list>
#include <string>
#include "thread.h"

#ifndef Q_MOC_RUN
#include <boost/shared_ptr.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
#endif

#include "rf/event/RFEventManager.h"
#include "rf/event/RFTimerFired.h"
#include "rf/event/rooftop_event.h"

namespace ProcessRouter {

class Listener;
class IOThread : public Thread {
    public:
        IOThread();
        ~IOThread();

        void addListener(Listener *listener);
        void removeListener(Listener *listener);
        void forkLoop();

        virtual void threadMain();

        struct ev_loop *loopStruct() { return m_loop; }

    private:
        void taskLoop(Rooftop::Task<IOThread> *);
        Rooftop::Task<IOThread> m_task;

        std::list<Listener*> m_listeners;
        struct ev_loop *m_loop;
        int m_evrunMode;
};

} // namespace end

#endif

